<{extend name="base" /}>
    <{block name="body" }>
        <div class="layui-body ">
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <li class="">
                            <a href="<{:url('admin/sm/index')}>">已添加列表</a>
                        </li>
                        <li >
                            <a href="<{:url('admin/sm/create',['style_id'=>1])}>">样式一</a>
                        </li>
                        <li >
                            <a href="<{:url('admin/sm/create',['style_id'=>2])}>">样式二</a>
                        </li>
                        <li class="layui-this">
                            <a href="<{:url('admin/sm/create',['style_id'=>3])}>">样式三</a>
                        </li>
                        <li>
                            <a href="<{:url('admin/sm/create',['style_id'=>4])}>">样式四</a>
                        </li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show" id="app">
                        <div class="left">
                            <form class="layui-form" method="post" action="<{:url('admin/sm/save')}>">
                                <input type="hidden" name="style" value="3">
                                <{php}>
                                if(request()->action() == 'edit'){
                                    echo '<input type="hidden" name="type" value="edit">';
                                    echo '<input type="hidden" name="id" value="'.request()->get('id').'">';
                                }
                                <{/php}>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">标题</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="content[title]"  lay-verify="required" v-model='title' placeholder="{用此符号可飘红，支持多个} 必须成对书写"
                                            class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">缩略图</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="content[thumb]" lay-verify="required" v-model='thumb' class="layui-input layui-input-inline" id="mythumb">
                                        <input type="file" name="file" class="layui-upload-file">
                                    </div>
                                </div>
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">描述</label>
                                    <div class="layui-input-block">
                                        <textarea name="content[desc]" lay-verify="required" required placeholder="{西宁长海医院}正规吗 西宁长海医院，医保{医院}，妇科检查28元，内分泌筛查套餐120元，医保定点，咨询热线"
                                            class="layui-textarea" v-model='desc'></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">链接</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="content[url]" v-model='url' required lay-verify="required|url" placeholder="例如：http://baidu.com" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">域名</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="content[host]" v-model='host' lay-verify="required" placeholder="例如：010-8888888" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-row">
                                    <div class="layui-col-md4">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">小标题一</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="content[data][title1]" v-model='title1' lay-verify="required" placeholder="医院简介" class="layui-input stitle-input">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-col-md8">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">链接</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="content[data][url1]" v-model='url1' lay-verify="required|url" placeholder="请输入链接" class="layui-input stitle-input">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-row">
                                    <div class="layui-col-md4">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">小标题二</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="content[data][title2]" v-model='title2' required lay-verify="required" placeholder="特色服务" class="layui-input stitle-input">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-col-md8">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">链接</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="content[data][url2]" v-model='url2' lay-verify="required|url" placeholder="请输入链接" class="layui-input stitle-input">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-row">
                                    <div class="layui-col-md4">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">小标题三</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="content[data][title3]" v-model='title3' required lay-verify="required" placeholder="优惠政策" class="layui-input stitle-input">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-col-md8">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">链接</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="content[data][url3]" v-model='url3' lay-verify="required|url" placeholder="请输入链接" class="layui-input stitle-input">
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="right" id="sm-search">
                            <link rel="stylesheet" href="/sm/css/style.css" />
                                <div  class="ad-container-silver ad-dot-container hasShowed">
                                    <a :href="url" >
                                        <div class="title" v-html="Ctitle"></div>
                                    </a>
                                    <div class="main-info">
                                        <a :href="url">
                                            <div class="img-box">
                                                <img :src="thumb">
                                            </div>
                                        </a>
                                        <dl>
                                            <a :href="url">
                                                <dd class="info-box" v-html="Cdesc"></dd>
                                            </a>
                                        </dl>
                                    </div>
                                    <div class="tag-box">
                                        <a :href="url1" v-html="Ctitle1"></a>|
                                        <a :href="url2" v-html="Ctitle2"></a>|
                                        <a :href="url3" v-html="Ctitle3"></a>
                                    </div>
                                    <div class="fn-clear contact-line">
                                        <a :href="url">
                                            <span class="web-link" v-html="Chost"></span>
                                            <span>广告</span>
                                        </a>
                                    </div>
                                </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
<{/block}>
<{block name="script" }>
                <style type="text/css">
                    .left,
                    .right {
                        float: left;
                    }

                    .left {
                        width: 60%;
                    }

                    .right {
                        height: 550px;
                        margin-left: 60px;
                        width: 300px;
                        border: 2px solid #ccc;
                        border-radius: 20px;
                        padding: 20px 13px;
                        background: #f1f1f1;
                        box-shadow: 1px 2px #eeeeee5c;
                    }
                </style>
                <script src="/static/js/vue.js"></script>
                <script type="text/javascript">
                    var vue = new Vue({
                        el: "#app",
                        data: {
                            title: '',
                            desc: '',
                            host: '',
                            url:'',
                            title1: '',
                            title2: '',
                            title3: '',
                            url1: '',
                            url2: '',
                            url3: '',
                            thumb: 'http://iph.href.lu/80x80'
                        },
                        computed: {
                            Ctitle: function () {
                                if (this.title == '') {
                                    return '「天猫电器城」中国<em>移动</em>网上商城网，正品低价！';
                                }
                                return this.title.replace(/{/g, '<em>').replace(/}/g, '</em>');
                            },
                            Cdesc: function () {
                                if (this.desc == '') {
                                    return '「天猫电器城」中国<em>移动</em>网上商城网，海量大牌电器，旗舰直营，更智慧，更懂你，天猫，安心之选！';
                                }
                                return this.desc.replace(/{/g, '<em>').replace(/}/g, '</em>');
                            },
                            Chost:function(){
                                if (this.host == '') {
                                    return '3c.tmall.com';
                                }
                                return this.host;
                            },
                            Ctitle1:function () {
                                if (this.title1 == '') {
                                    return '医院简介';
                                }
                                return this.title1;
                            },
                            Ctitle2:function () {
                                if (this.title2 == '') {
                                    return '特色服务';
                                }
                                return this.title2;
                            },
                            Ctitle3:function () {
                                if (this.title3 == '') {
                                    return '来院路线';
                                }
                                return this.title3;
                            },
                        }
                    });

                    <{php}>
                        if(request()->action() == 'edit'){

                            echo "vue.title = '".$data['content']['title']."';";
                            echo "vue.desc = '".$data['content']['desc']."';";
                            echo "vue.host = '".$data['content']['host']."';";
                            echo "vue.url = '".$data['content']['url']."';";
                            echo "vue.thumb = '".$data['content']['thumb']."';";

                            echo "vue.title1 = '".$data['content']['data']['title1']."';";
                            echo "vue.title2 = '".$data['content']['data']['title2']."';";
                            echo "vue.title3 = '".$data['content']['data']['title3']."';";
                            echo "vue.url1 = '".$data['content']['data']['url1']."';";
                            echo "vue.url2 = '".$data['content']['data']['url2']."';";
                            echo "vue.url3 = '".$data['content']['data']['url3']."';";
                            
                        }
                    <{/php}>


                    $(function () {
                        layui.upload({
                            url: "/api/upload/upload",
                            type: 'image',
                            ext: 'jpg|png|gif|bmp',
                            success: function (data) {
                                if (data.error === 0) {
                                    document.getElementById('mythumb').value = data.url;
                                    vue.thumb = data.url; //映射到vue
                                    $(".c-img>img").attr('src', data.url);
                                } else {
                                    layer.msg(data.message);
                                }
                            }
                        });
                    });
                </script>
                <{/block}>